﻿using System;
using System.Web.Security;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Marbles.CMS.ContentTypes;

namespace Marbles.CMS.Administrator.Content
{
    public partial class UserList : ContentEditorBase 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "User Accounts";

            if (!Page.IsPostBack)
            {
                LoadUsers();
            }
        }

        private void LoadUsers()
        {             
            grdUsers.DataSource = Membership.GetAllUsers();
            grdUsers.DataBind();
        }

        protected void grdUsers_RowDatabound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow) { return; }
            MembershipUser u = e.Row.DataItem as MembershipUser;
            e.Row.ToolTip = u.UserName;
            e.Row.Style.Add("cursor", "hand");
            e.Row.Attributes.Add("onclick", string.Format("window.location.href='?action=User&uid={0}';", u.UserName));
            e.Row.Attributes.Add("onmouseover", "this.className='MenuBarItemHover';");
            e.Row.Attributes.Add("onmouseout", "this.className='';");
        }
    }
}
